/**
 *氢氧化钙
 */
Bottle1 = Widget.extend({
	ctor:function(parent){
		this._super();
		parent.addChild(this,31,TAG_BOTTLE1_ALL);
		this.init();
	},
	init : function(){
		var bottle1=new Button(this,10,TAG_BOTTLE1,"#bottle3.png",this.callback,this);
		bottle1.setPosition(cc.p(680, 280));
		bottle1.setAnchorPoint(0.5,0.5);

		var line1=new Button(bottle1,9,TAG_LINE1,"#line.png",this.callback,this);
		line1.setPosition(cc.p(bottle1.width*0.5, bottle1.height*0.35));
		line1.setAnchorPoint(0.5,0.5);
		
		var title1=new Button(bottle1,9,TAG_TITLE1,"#title1.png",this.callback,this);
		title1.setPosition(cc.p(bottle1.width*0.5, bottle1.height*0.45));

		var lid=new Button(this,9,TAG_LID1,"#lid1.png",this.callback,this);
		lid.setPosition(cc.p(680, 370));
	},
	rotateLine:function(){
		var rotate=cc.rotateBy(1,83);
		var scale=cc.scaleBy(1,1.5);
		var move=cc.moveBy(1, cc.p(0, 15));
		var bottle1=this.getChildByTag(TAG_BOTTLE1);
		var line=bottle1.getChildByTag(TAG_LINE1);
		line.runAction(cc.spawn(rotate,scale,move));
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		}, this);
		switch(p.getTag()){
		case TAG_LID1:
			var ber=cc.bezierBy(1, [cc.p(30,50),cc.p(65, 80),cc.p(88, -180)]);
			var rotate=cc.rotateBy(1,180);
			p.runAction(cc.sequence(cc.spawn(ber,rotate),func));
			break;
		case TAG_BOTTLE1:
			var ber=cc.bezierBy(1, [cc.p(-50, 100),cc.p(-125, 168),cc.p(-255,370)]);
			var rotate=cc.rotateBy(1,-85);
			var lid=this.getChildByTag(TAG_LID1);
			p.runAction(cc.sequence(cc.spawn(cc.callFunc(function() {
				ll.run.rack.takeTube1();
			},this),ber,rotate,cc.callFunc(function() {
				this.rotateLine()
			},this)),cc.callFunc(function() {
				ll.run.rack.upLine1();
			},this),cc.delayTime(1),cc.callFunc(function() {
				ll.run.rack.putTube1();
			}, this),cc.callFunc(function(){
				lid.removeFromParent(true);
				p.removeFromParent(true);
			},this),func));
			break;
		}
	}
});
